Using the Camera node

Use the Camera node to show the content of a Scene in your Kanzi Studio project and in your Kanzi application. When you create a Scene it contains only a Camera node and a Directional Light. This is the default Camera node and preview camera for that Scene. When a Camera node is a preview camera, in the Preview you see the Scene through that Camera node. In the Project the preview camera is marked with (Preview).

Setting the position of Camera nodes

To set the position of a Camera node:

  1. In the Preview click Edit to enter the Edit mode and select the Camera tool.
  2. In Camera tool you can use either orbit or free camera:

  3. When setting the position of a Camera node use these controls:
    ControlDescription

    Store the current position of the camera to the preview Camera node.

    Reset the camera to the current position of the preview Camera node.

    Create a new Camera node from the current position of the camera.

    Bring the camera to the 3D object selected in the Project or the Preview.

    Select the Camera node through which you want to view the current scene.

    Set the field of view for the camera in degrees when working with 3D nodes.

Turning a Camera node into a preview camera

When a Camera node is a preview camera, in the Preview you see the Scene through that Camera node. In the Project the preview camera is marked with (Preview).

To turn a Camera node into a preview camera:

Or

  1. In the Project select the scene where you what to turn a Camera node into a preview camera.
  2. In the Properties in property Camera > Preview Camera select the Camera node you want to use as the preview camera.

If the scene is not visible in the Preview even after you set a preview camera, you need to activate the scene. See Using the Scene node.

Viewing the active Scene from the preset viewpoints

The Camera tool allows you to quickly view the content of an entire Scene from one of the preset viewpoints: front, back, top, bottom, left, or right side. Unless you switched on the option to store the current position of the camera (), the preset viewpoints do not change the position of the Camera nodes in a Scene. See Setting the position of Camera nodes.

To view the entire active Scene from a preset viewpoint:

  1. In the Preview click Edit to enter the Edit mode and select the Camera tool.
  2. Use these shortcuts:
    Preset viewpointShortcut
    View an entire Scene from the left side.Shift+1
    View an entire Scene from the right side.Shift+2
    View an entire Scene from the top.Shift+3
    View an entire Scene from the bottom.Shift+4
    View an entire Scene from the front.Shift+5
    View an entire Scene from the back.Shift+6

Creating a new Camera node

You can create a new Camera node in these ways:

  1. In the Preview click Edit to enter the Edit mode and select the Camera tool.
  2. Use either the orbit or free camera to move to the location where you want to create a new camera and click . See Setting the position of Camera nodes.
    Kanzi Studio creates a new Camera node in the position of the camera.

Or

Setting the projection type of a Camera node

To set the projection type of a Camera node, in the Project select the Camera node and in the Properties set the Projection Type property:

Using the Camera node in the API

Create a camera with a perspective projection:

// Create a camera named Camera.
CameraSharedPtr camera = Camera::create(domain, "Camera");
// Set the projection of the camera to perspective.
camera->setPerspectiveProjection();

// Make the viewing box display a horizontal 90 degree cone of the 3D space.
// The vertical cone angle is determined by the viewport aspect ratio.
camera->setFovType(Camera::YFov);
camera->setFov(90.0f);
camera->setZNear(0.1f);
camera->setZFar(100.0f);

Create a camera with an orthographic projection:

// Create a camera named Camera.
CameraSharedPtr camera = Camera::create(domain, "Camera");
// Set the projection of the camera to relative orthogonal.
camera->setOrthogonalProjection(Camera::OrthogonalCoordinateSystemRelative);

// Make the viewing box display [-width,width] x [-1, 1] x [-1, 1] portion of the 3D space.
// The width of the viewing box is determined by the viewport aspect ratio.
camera->setOrthogonalPlaneHeight(1.0f);
camera->setZNear(-1.0f);
camera->setZFar(1.0f);

For details, see the API reference.

See also

Making objects turn to a camera

Camera nodes

Editing your application in the Preview